<template>
  <div>
    <mt-header title="维修接单">
      <router-link to="/" slot="left">
        <mt-button icon="back"></mt-button>
      </router-link>
      <mt-button slot="right" v-on:click="popVisibleChange()">筛选</mt-button>
    </mt-header>
    <div>
      <BillItem v-for="child in billlist" :child-data="child"></BillItem>
    </div>


    <mt-popup
      class="pop"
      v-model="popupVisible"
      position="center"
      popup-transition="popup-fade">
      <div style="padding: 20px">
        <mt-field label="签发始日期" placeholder="" type="date" v-model="kssj"></mt-field>
        <mt-field label="签发止日期" placeholder="" type="date" v-model="jssj"></mt-field>
        <mt-field label="工单编号" placeholder=""></mt-field>
        <mt-radio v-model="gdzt" :options="options" @change="showToast()"></mt-radio>
        <mt-button type="primary" size="large" v-on:click="getBills()">查询</mt-button>
      </div>
    </mt-popup>
  </div>
</template>

<script>
  import BillItem from '../components/BillItem'

  export default {
    created() {
      this.getBills();
    },
    name: "BillPage",
    components: {
      BillItem
    },
    data() {
      return {
        userid: '997',
        usertype: '0',
        kssj: '',
        jssj: '',
        gdzt: '0',
        gdno: '',
        billlist: [],
        popupVisible: false,
        options: [{label: '未接单', value: '0'}, {label: '已接单', value: '1'}]
      }
    },
    computed: {},
    methods: {
      getBills() {
        var that = this;
        that.$indicator.open(
          {
            text: '加载中...',
            spinnerType: 'fading-circle'
          }
        );
        var params = new Object();
        // var url = 'http://192.168.183.10:8080/bill/getBills';//实业的ip
        var url = global.BASE_URL+'/bill/getBills';
        params.userid = this.userid;
        params.usertype = this.usertype;
        params.kssj = this.kssj;
        params.jssj = this.jssj;
        params.gdzt = this.gdzt;
        params.fgdno = this.gdno;
        this.$http({
          method: 'GET',
          url: url,
          params: params,
        })
          .then(function (responce) {
            that.$indicator.close();
            console.log(responce)
            var response1 = responce.data;
            var errorCode = response1.errorCode;
            var errorMessage = response1.errorMessage;
            that.billlist = response1.data;
            if (that.popupVisible) {
              that.popupVisible = false
            }
          }).catch(function (error) {
          that.$indicator.close();
          console.log(error)
        })
      },
      showToast() {
        console.log(this.gdzt)
      },
      popVisibleChange() {
        if (this.popupVisible) {
          this.popupVisible = false
        } else {
          this.popupVisible = true
        }
      },
      gotoEdit(fid) {
        this.$router.push({name: 'EditBillPage', params: {'fid': fid}});
      }
    }
  }
</script>

<style scoped>
  .pop {
    border: 2px;
    border-style: solid;
    border-color: #EEEEEE;
    width: 80%;
    height: auto;
    background: white;
    border-radius: 5px;
  }
</style>
